package top.houry.test;

import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import top.houry.grpc.proto.OpenAPIGrpc;
import top.houry.grpc.proto.TestGrpc;

public class ServerStreamingClientGrpc {
    public static void main(String[] args) {
        ManagedChannel channel = ManagedChannelBuilder.forAddress("localhost", 9999).usePlaintext().build();
        OpenAPIGrpc.OpenAPIBlockingStub stub = OpenAPIGrpc.newBlockingStub(channel);
        TestGrpc.Request request = TestGrpc.Request.newBuilder().setName("小猴子").build();
        stub.serverStreaming(request).forEachRemaining(response -> {
            System.out.println("接收到消息 " + response.getMessage());
        });
        channel.shutdown();
    }
}


